<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>table模块快速使用</title>
    <link rel="stylesheet" href="/static/layui/css/layui.css" media="all">
    <script src="/static/layui/layui.js"></script>
    <script src="/static/js/jquery.min.js"></script>
</head>
<body>

<form class="layui-form" action="">
    <input type="hidden" value="${model.limitId}" name="limitId">
    <div class="layui-form-item">
        <label class="layui-form-label">Menu name</label>
        <div class="layui-input-block">
            <input type="text" name="limitName" value="${model.limitName}"  required  lay-verify="required" placeholder="Please enter a menu name" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">Web url</label>
        <div class="layui-input-block">
            <input type="text" name="limitUrl" value="${model.limitUrl}"  required  lay-verify="required" placeholder="Please enter a jump link" autocomplete="off" class="layui-input">
        </div>
    </div>
    <c:if test="${model.limitPid !='0'}">
        <div class="layui-form-item">
            <label class="layui-form-label">High menu</label>
            <div class="layui-input-block">
                <select name="limitPid" id="limitPid" lay-verify="required">
                    <c:forEach items="${list}" var="l">
                        <option value="${l.limitId}" <c:if test="${model.limitPid==l.limitId}">selected="selected"</c:if> >${l.limitName}</option>
                    </c:forEach>
                </select>
            </div>
        </div>
    </c:if>

    <div class="layui-form-item">
        <label class="layui-form-label">Sort</label>
        <div class="layui-input-block">
            <input type="text" name="sortId" value="${model.sortId}" required  lay-verify="required|number" placeholder="Please enter a number" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit lay-filter="formDemo">Submit</button>
            <button type="reset" class="layui-btn layui-btn-primary">Reset</button>
        </div>
    </div>
</form>


<script>
    layui.use(['form','layer'], function(){
        var form = layui.form,
            layer=layui.layer;
        form.on('submit(formDemo)', function(data){
            $.ajax({
                url : '/manage/limit/edit',
                type : 'post',
                dataType : 'json',
                data : data.field,
                success : function (data) {
                    if (data.code == 200){
                        layer.msg(data.msg,{icon: 1, time: 500},function (index) {
                            layer.close(index);
                            window.parent.location.reload();
                        });
                    }else{
                        layer.msg(data.msg,{icon: 2, time: 1000});
                    }
                }
            })
            return false;
        });
    });

</script>

</body>
</html>
